package alogrithm;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author lbw
 * @version 1.0
 * @date 2021/10/26 21:11
 */
public class LRUCacheDemo1 extends LinkedHashMap {

    private int cacheSize;

    public LRUCacheDemo1(int initialCapacity) {
        super(initialCapacity);
        this.cacheSize = initialCapacity;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry eldest) {
        return cacheSize > size();
    }
}
